/**
 *   This file is part of Java Simple Sampler.
 *
 *   Java Simple Sampler is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License.
 *
 *   Java Simple Sampler is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with Java Simple Sampler.  If not, see <http://www.gnu.org/licenses/>.
 *
 *   @author David Lapetina	
 */

package net.onirik.mao.sampler.sound;

import java.util.HashMap;
import java.util.Map;

public class SamplePlayerMap {
	private final Map map = new HashMap();

	private SamplePlayer defaultPlayer = null;

	public SamplePlayerMap() {
	}

	public SamplePlayer getDefaultPlayer() {
		return defaultPlayer;
	}

	public SamplePlayerMap(SamplePlayer defaultPlayer) {
		this.defaultPlayer = defaultPlayer;
	}

	public void addSamplePlayer(int note, SamplePlayer player) {
		map.put(new Integer(note), player);
	}

	public SamplePlayer getSamplePlayer(int note, boolean useDefault) {
		Integer key = new Integer(note);
		if (map.containsKey(key))
			return (SamplePlayer) map.get(key);
		if (useDefault)
			return defaultPlayer;
		return null;
	}

	public void setDefaultPlayer(SamplePlayer defaultPlayer) {
		this.defaultPlayer = defaultPlayer;
	}
}
